package net.sx.minemodule.mvp.presenters;

import com.kedll.library.mvp.BasePresenter;

import net.sx.minemodule.MineApiUtils;
import net.sx.minemodule.mvp.bean.LogisticsCompany;
import net.sx.minemodule.mvp.bean.RefundBean;
import net.sx.minemodule.mvp.views.MineRefundInputLogisticsView;

import java.util.ArrayList;
import java.util.List;

import io.reactivex.Observable;

/**
 * Created by Administrator 可爱的路人 on 2019/7/6.
 * Email:513421345@qq.com
 * 填写售后订单回寄物流信息
 */
public class MineRefundLogisticsPresenter extends BasePresenter<MineRefundInputLogisticsView> {

    public MineRefundLogisticsPresenter(MineRefundInputLogisticsView view) {
        super(view);
    }

    /**
     * 提交物流信息
     */
    public void commitLogisticsInfo(LogisticsCompany company) {

        MineApiUtils.ensureAfterOrder(company, result -> {
            mView.commitSuccess();
        }, throwable -> {
            mView.commitFail(throwable.getMessage());
        });
    }

    /**
     * 获取物流公司列表
     */
    public void getLogisticsCompanys() {
        List<LogisticsCompany> companyList = new ArrayList<>();
        companyList.add(new LogisticsCompany("0", "顺丰快递"));
        companyList.add(new LogisticsCompany("1", "申通快递"));
        companyList.add(new LogisticsCompany("2", "圆通快递"));
        companyList.add(new LogisticsCompany("3", "中通快递"));
        companyList.add(new LogisticsCompany("4", "国通快递"));
        companyList.add(new LogisticsCompany("5", "韵达快递"));
        companyList.add(new LogisticsCompany("6", "百世汇通"));
        companyList.add(new LogisticsCompany("7", "宅急送"));
        addSubscription(
                Observable.just(companyList)
                        .subscribe(logisticsCompanies -> {
                            mView.getLogisticsCompanySuccess(logisticsCompanies);
                        })
        );
    }
}
